package com.syni.mdd.yhd.common.all.service.impl;

import com.syni.mdd.yhd.common.all.dao.jpa.BmsSuperPwdDao;
import com.syni.mdd.yhd.common.all.entity.BmsSuperPwd;
import com.syni.mdd.yhd.common.all.service.BmsCommonService;
import com.syni.mdd.yhd.common.all.service.BmsSuperPwdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @className
 * @description TOO
 * @Author cfx
 * @DATE 2019/4/9 12:04
 * @VERSION 1.0
 **/
@Service
public class BmsSuperPwdServiceImpl implements BmsSuperPwdService {
    @Autowired
    BmsSuperPwdDao bmsSuperPwdDao;

    @Override
    public BmsSuperPwdDao getBaseDao() {
        return bmsSuperPwdDao;
    }

    @Override
    public String findSuperPwd() {
        Pageable pageable = BmsCommonService.getPageable(1,1, Sort.Direction.DESC,"newTime");
        List<BmsSuperPwd> bmsSuperPwds = bmsSuperPwdDao.findAll(pageable).getContent();
        if(bmsSuperPwds != null && bmsSuperPwds.size() > 0){
            return bmsSuperPwds.get(0).getSuperPwd();
        }
        return "-1";
    }
}
